package com.mirror.util;

import org.json.JSONObject;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.Date;

public class SortClass2 implements Comparator {
    public int compare(Object arg0, Object arg1) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        JSONObject a = (JSONObject) arg0;
        JSONObject b = (JSONObject) arg1;
        Date da = null;
        Date db = null;
        try {
            da = sdf.parse((String) a.getString("time"));
            db = sdf.parse((String) b.getString("time"));
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        int flag = da.compareTo(db);
        return flag;
    }
} 
